// import lazy from "@/components/diectives/lazy";
// // require.context 批量导入模块
// // 1.目录, 2. 是否在子目录中查找模块, 3. 通过正则匹配文件
// const importFN = require.context("./", false, /.vue$/);
// // 通过keys方法获取匹配到的所有文件路径,返回值为数组类型
// const keys = importFN.keys();
// const library = {
//   install(app) {
//     app.directive("lazy", lazy);
//     // 遍历所有文件
//     keys.forEach((key) => {
//       // 导入组件
//       const component = importFN(key).default;
//       // 注册组件//
//       app.component(component.name, component);
//     });
//   },
// };
// export default library;
// 批量导入模块

const importFn = require.context("./", false, /.vue$/);
import lazy from "@/components/diectives/lazy";
import Message from "@/components/library/Message";
// 通过keys方法获取所有模块
const keys = importFn.keys();

const library = {
  install(app) {
    app.directive("lazy", lazy);
    app.config.globalProperties.$message = Message;
    keys.forEach((key) => {
      const component = importFn(key).default;
      app.component(component.name, component);
    });
  },
};
export default library;
